home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Tech Arsenal 1
/
Tech Arsenal (Arsenal Computer).ISO
/
tek-01
/
wtek0693.zip
/
OOPALLEY.ZIP
/
ASSOCINT.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1993-04-27
|
1KB
|
42 lines
/* AssocInt.c -- implementation of key-Integer association
Function:
Objects of class AssocInt associate a key object with an Integer value
object. They are used to implement Bags, which use a Dictionary to
associate objects with their occurrence counts.
*/
#include "assocint.h"
#define THIS AssocInt
#define BASE LookupKey
//DEFINE_CLASS(THIS, BASE);
DEFINE_CLASS(AssocInt,LookupKey);
AssocInt::AssocInt(const Object& newKey, int newValue)
: LookupKey(newKey), avalue(newValue) {}
Object* AssocInt::value() const { return (Object*)&avalue; }
Object* AssocInt::value(const Object& newValue)
{
assertArgClass(newValue,class_Integer,"value");
avalue = *(Integer*)&newValue;
return &avalue;
}
void AssocInt::deepenShallowCopy()
{
BASE::deepenShallowCopy();
avalue.deepenShallowCopy();
}
void AssocInt::printOn(ostream& strm) const
{
strm << className() << "("; BASE::printOn(strm);
strm << "="; avalue.printOn(strm); strm << ")";
}